import type { PageParams, PageResult, ProducTItem } from '@/types/global'
import type { BannerItem, CategoryItem, HotItem } from '@/types/home'
import { http } from '@/utils/http'
import { http as https } from '@/utils/https'

/**
 *
 * @param distributionSite 广告区域展示位置
 * @returns
 */

export const getHomeBannerAPI = (distributionSite = 1) => {
  return http<BannerItem[]>({
    method: 'GET',
    url: '/home/banner',
    data: {
      distributionSite,
    }
  })
}

export const getAllGoods = async () => {
  try {

    const data = await uni.request({
      method: 'GET',
      url: '/commodity/all'
    })

    return data.data;
  } catch (error) {
    return error;
  }
}
/**
 * 首页 分类 小程序
 */

export const getHomeCategoryAPI = () => {
  return http<CategoryItem[]>({
    method: 'GET',
    url: '/home/category/mutli'
  })
}

/**
 * 首页 热门推荐
 */

export const getHomeHot = () => {
  return http<HotItem[]>({
    method: 'GET',
    url: '/home/hot/mutli'
  })
}

/**
 * 猜你喜欢
 */

export const getHomeGoodsuessLikeAPI1 = (data?: PageParams) => {
  return http<ProducTItem>({
    method: 'GET',
    url: '/commodity/all',
    data,
  })
}

/**
 * 猜你喜欢
 */

export const getHomeGoodsuessLikeAPI = (data?: PageParams) => {
  return https<ProducTItem[]>({
    method: 'GET',
    url: '/commodity/all',
    data,
  })
}
